/*
   @Copyright:LeetCode
   @Author:   tjyemail
   @Problem:  http://leetcode.com/problems/group-anagrams
   @Language: C++
   @Datetime: 19-06-19 15:27
   */

class Solution {
public:
	vector<vector<string> > groupAnagrams(vector<string> &strs) {
		unordered_map<string,vector<string> > dict;
		for(int i=0; i<strs.size(); ++i){
			string str=strs[i];
			sort(str.begin(),str.end());
			dict[str].push_back(strs[i]);
		}
		vector<vector<string> > vs;
		for(const auto &p:dict)
			vs.push_back(p.second);
		return vs;
	}
};
